﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Text;
using Amib.Threading;

namespace HPPClientLibrary
{
    using DownLoad;

    public interface IClient
    {

        /// <summary>
        /// 客户端服务器监听端口
        /// </summary>
        int CSServerListenPort{ get; }

        /// <summary>
        /// 正在连接或已经连接的中央服务器EndPoint
        /// </summary>
        IPEndPoint ConnectServerEndPoint { get; }

        /// <summary>
        /// 线程池
        /// </summary>
        SmartThreadPool ThreadPool { get; }

        /// <summary>
        /// 添加到共享目录列表
        /// </summary>
        /// <param name="dir">被添加的列表</param>
        void AddShareDir(string dir);
        void AddShareDir(IEnumerable<string> addList);
        /// <summary>
        /// 返回只读的共享目录列表
        /// </summary>
        /// <returns>只读的列表</returns>
        IEnumerable<string> ReadOnlyShareDir { get; }

        /// <summary>
        /// 返回只读的已Hash列表
        /// </summary>
        /// <returns>只读的列表</returns>
        IEnumerable<string> ReadOnlyKnownDict { get; }

        /// <summary>
        /// 返回只读的Hash-全路径对应列表
        /// </summary>
        /// <returns>只读的列表</returns>
        //ReadOnlyDictionary<string, string> ReadOnlyHashFullNameDict { get; }

        ReadOnlyDictionary<string, HppFileInfo> ReadOnlyHashFileInfoDict { get; }



        /// <summary>
        /// 开始下载某个Hash的文件
        /// </summary>
        /// <param name="hash">要下载的Hash值</param>
        /// <param name="saveFilePath">要保存到的本地文件系统路径</param>
        /// <param name="isStartNow">是否立即开始下载</param>
        void Download(string hash, string fileName, bool isStartNow);

        /// <summary>
        /// 客户端服务器开始监听
        /// </summary>
        void StartListen();

        /// <summary>
        /// 连接到中央服务器
        /// </summary>
        /// <param name="ipEndPoint"></param>
        void ConnectServer(IPEndPoint ipEndPoint);
        /// <summary>
        /// 是否已连接到中央服务器
        /// </summary>
        bool Connected { get; }
        /// <summary>
        /// 上传共享目录
        /// </summary>
        void UploadShareDir(IPEndPoint ipEndPoint);

        /// <summary>
        /// 向中央服务器搜索
        /// </summary>
        /// <param name="filename">搜索关键字</param>
        void Search(string filename);

        /// <summary>
        /// 下载管理器
        /// </summary>
        DownloadManager DownloadManager { get; }

        ConfigManager Config { get; }
    }
}
